package com.itly.rwgh.controller;

import com.itly.rwgh.pojo.*;
import com.itly.rwgh.service.VisualizationService;
import com.itly.rwgh.utils.BubbleSort;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: 罗言
 * @Version: 1.0
 * @Date: 2023-12-26-14:05
 * @Description: 可视化数据集
 */
@Controller
@RequestMapping("/vis")
public class VisualizationController {

    @Autowired
    private VisualizationService service;

    @GetMapping("/data1")
    @ResponseBody
    public Result getData1() {
        List<DataModel> data = service.getHr();
        return new Result(data != null ? Code.GET_OK : Code.GET_ERR, BubbleSort.sort(data));
    }
    @GetMapping("/data2")
    @ResponseBody
    public Result getData2() {
        List<DataModel> data = service.getPa();
        return new Result(data != null ? Code.GET_OK : Code.GET_ERR, data);
    }
    @GetMapping("/data3")
    @ResponseBody
    public Result getData3() {
        List<DataModel> data = service.getCountT();
        return new Result(data != null ? Code.GET_OK : Code.GET_ERR, data);
    }
    @GetMapping("/data4")
    @ResponseBody
    public Result getData4() {
        List<DataModel> data = service.getInfoT();
        return new Result(data != null ? Code.GET_OK : Code.GET_ERR, data);
    }
    @GetMapping("/data5")
    @ResponseBody
    public Result getData5() {
        List<DataModel> data = service.getWd();
        return new Result(data != null ? Code.GET_OK : Code.GET_ERR, data);
    }
    @GetMapping("/data6")
    @ResponseBody
    public Result getData6() {
        List<DataModel> data = service.getWeather();
        return new Result(data != null ? Code.GET_OK : Code.GET_ERR, data);
    }
    @GetMapping("/data7")
    @ResponseBody
    public Result getData7() {
        List<DataModel> data = service.getWp();
        return new Result(data != null ? Code.GET_OK : Code.GET_ERR, data);
    }
    @GetMapping("/data8")
    @ResponseBody
    public Result getData8() {
        List<DataModel> data = service.getWs();
        return new Result(data != null ? Code.GET_OK : Code.GET_ERR, data);
    }

    @GetMapping("/data9")
    @ResponseBody
    public Result getData9() {
        Integer count = service.getDataCount();
        return new Result(count >= 0 ? Code.GET_OK : Code.GET_ERR, count);
    }

    @PostMapping("/data10")
    @ResponseBody
    public Result getData10(@RequestBody PageLimit limit) {
        List<DataPage> data = service.getData(limit);
        return new Result(data != null ? Code.GET_OK : Code.GET_ERR, data);
    }
}
